package slid.menu;

import com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.OnPageChangeListener;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnCloseListener;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SlidDemoActivity extends Activity {
    /** Called when the activity is first created. */
	private Button btn;
	private SlidingMenu menu;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        menu = new SlidingMenu(this);
        menu.setMode(SlidingMenu.LEFT);
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
//        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
        menu.setShadowWidthRes(R.dimen.shadow_width);
        menu.setShadowDrawable(R.drawable.shadow);
        menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
        menu.setFadeDegree(0.35f);
        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        menu.setMenu(R.layout.slide_menu);
        
        btn = (Button) findViewById(R.id.btn);
        menu.openMenu();
        btn.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if (menu.isMenuShowing()) {
					menu.closeMenu();
				} else {
					 menu.openMenu();
				}
			}
		});
        
        menu.mViewAbove.setOnPageChangeListener(new OnPageChangeListener() {
			
			public void onPageSelected(int position) {
				// TODO Auto-generated method stub
				
			}
			
			public void onPageScrolled(int position, float positionOffset,
					int positionOffsetPixels) {
				if(Math.abs(positionOffset) < 0.6){
					finish();
				}
			}
		});
      
    }
	 
}